<?php
require DT_CORE.'/buyhelp/common.inc.php';
defined('IN_IXDCW') or exit('Access Denied');
$navname        = 'drive';
$MOD['name']    = '买车助手_试驾';


$table      = Table::name(Table::NAME_CATEGORY);
/*筛选项*/
$typeArr    = $db->getAll("select catid,catname from $table where parentid=3592 order by listorder");
foreach($typeArr as $val) {
	$TYPES[$val['catid']] = $val['catname'];
}

// normal
$filter['catid'] = getgpc('catid');


/*车型类别 车系id*/
$autoId     = AutoCategoryModule::getCarbylevel($cartypeid);


/*试驾类别：试驾体验 进口车 国产车*/
//$catIdSql   = "select arrchildid from $table where catid=3592";


/*试驾 类别筛选*/
foreach($TYPES as $id => $name) {
	if($catid == $id) $condition    = "catid=$catid";
	$catids[] = $id;
}
$catids = implode(',',$catids);
if(!isset($condition)) $condition   = "catid in($catids)";


/*车系 筛选*/
$condition .= " and arcid in($autoId)";
$condition .= " and status=3 ";

$table      = Table::name(Table::NAME_GUIDE);
$total      = $db->count($table, $condition, $DT['cache_search']);
$do         = new BuyModule($moduleid);
if ($total) {
	$latestDrive = $do->getList($condition,'edittime DESC',($DT['cache_search'] && $page == 1) ? 'CACHE' : '', $DT['cache_search']);
	if ($page == 1 && $kw) keyword($kw, $items, $moduleid);
}


include template('driveList','buyhelp');